<template>
        <tr>
          <td>
            <input type="checkbox" v-model="item.checked" @change="changeFn" />
          </td>
          <td>{{item.name}}</td>
          <td>{{item.price}}</td>
          <td><button @click="changeCount(-1)">-</button> {{item.num}} <button @click="changeCount(1)">+</button></td>
          <td>{{item.price * item.num}}</td>
          <td><button @click="delFn">删除</button></td>
        </tr>
</template>

<script>
export default {
  props:{
    item:{
      type:Object
  }},
  methods:{
    changeCount(num){
      const count = this.item.num + num
      if(count < 1) return
      this.$store.commit('updateCount',{name:this.item.name,count:count})
    },
    delFn(){
      this.$store.commit('updateList',this.item.name)
    },
    changeFn(){
      this.$store.commit('updateCheck',{name:this.item.name,checked:this.item.checked})
    }
  },
  data() {
    return {
    };
  },
};
</script>

<style>
</style>